#include "stdafx.h"
#include "AxisObj.h"

CAxisObj::CAxisObj()
{
	m_Verteices[_x].pos = D3DXVECTOR3(-10.f, -1.0f, 0.0f);
	m_Verteices[ x].pos = D3DXVECTOR3( 10.f, -1.0f, 0.0f);
	m_Verteices[_y].pos = D3DXVECTOR3(0.0f, -10.0f, 0.0f);
	m_Verteices[ y].pos = D3DXVECTOR3(0.0f,  10.0f, 0.0f);
	m_Verteices[_z].pos = D3DXVECTOR3(.0f, -1.f, -10.0f);
	m_Verteices[ z].pos = D3DXVECTOR3(.0f, -1.f, 10.0f);

	for (int i = 0; i < 6; i++)
	{
		m_Verteices[i].normal = D3DXVECTOR3(0.f, 0.f, -1.f);
		m_Verteices[i].diff = D3DCOLOR_XRGB(0xff, 0x0, 0xff);
	}

	for (int i = 0; i < 50; i++)
	{
		m_GridsX[i*2].pos.x = i - 25.f;
		m_GridsX[i*2].pos.y = 0;
		m_GridsX[i*2].pos.z = 25.f;

		m_GridsX[i*2+1].pos.x = i - 25.f;
		m_GridsX[i*2+1].pos.y = 0;
		m_GridsX[i*2+1].pos.z = -25.f;

		m_GridsY[i*2].pos.x = 25.f;
		m_GridsY[i*2].pos.y = 0;
		m_GridsY[i*2].pos.z = i - 25.f;

		m_GridsY[i*2+1].pos.x = -25.f;
		m_GridsY[i*2+1].pos.y = 0;
		m_GridsY[i*2+1].pos.z = i - 25.f;

		m_GridsX[i*2].diff = D3DCOLOR_XRGB(0x0, 0x5f, 0x0);
		m_GridsX[i*2 + 1].diff = D3DCOLOR_XRGB(0x0, 0x5f, 0x0);
		m_GridsY[i*2].diff = D3DCOLOR_XRGB(0x0, 0x5f, 0x0);
		m_GridsY[i*2 + 1].diff = D3DCOLOR_XRGB(0x0, 0x5f, 0x0);

		m_GridsX[i*2].normal		= D3DXVECTOR3(0.f, 0.f, -1.f);
		m_GridsX[i*2 + 1].normal	= D3DXVECTOR3(0.f, 0.f, -1.f);
		m_GridsY[i*2].normal		= D3DXVECTOR3(0.f, 0.f, -1.f);
		m_GridsY[i*2 + 1].normal	= D3DXVECTOR3(0.f, 0.f, -1.f);
	}
}

CAxisObj::~CAxisObj()
{

}

void CAxisObj::Render(IDirect3DDevice9*	aPDevice)
{
	aPDevice->SetFVF(AxisFVF);
	//aPDevice->DrawPrimitiveUP(D3DPT_LINELIST, 3, &m_Verteices, sizeof(AxisVertex));
	aPDevice->DrawPrimitiveUP(D3DPT_LINELIST, 50, &m_GridsX, sizeof(AxisVertex));
	aPDevice->DrawPrimitiveUP(D3DPT_LINELIST, 50, &m_GridsY, sizeof(AxisVertex));
}

